let app = getApp()
Component({
    properties: {
      pageInfo: {
        type: Object,
        observer: function(newVal, oldVal) {
          this.updateRate()
        }
      }
      },
      data:{
      
      },
    lifetimes: {
        attached: function () {
          if(wx.getStorageSync('choosedAccount')==''){
            var cur=this.data.pageInfo ? this.data.pageInfo.index : 0
            this.setData({
                cur:cur
            })
          }else{
            this.setData({
              cur:wx.getStorageSync('choosedAccount').index
            })
          }
         
       }
      },
    methods: {
      chooseaccount:function(e){
         var index=e.currentTarget.dataset.index
         var choosedAccount={
          cardId:this.data.pageInfo.cardInfo[index].id,
          index:index
         };
         wx.setStorageSync('choosedAccount',choosedAccount);
         wx.navigateBack({
          delta: -1
         })
      },
      updateRate:function(){
        var cur=this.data.pageInfo ? this.data.pageInfo.index : 0
        this.setData({
            cur:cur
        })
      }
    }
});
